// xc_lshop/distr/shareholder/bonus.js
var distr_shareholderbill = require('../model/distribution_shareholder')

Page({
  mixins: [require('../../../xc/mixins/basicMixin')],

  /**
   * 页面的初始数据
   */
  data: {
    xcmodel:null
  },
  xcloaddata: function (options, config) {
    this.getbasic()
    this.getpagelist(1)
  },
  getbasic(){
    var that = this;
    distr_shareholderbill.getbasic().then(function (rst) {
      console.log("rst")
      console.log(rst)

      if (rst["status"] == 1) {
        that.setData({
          'xcmodel': rst["obj"]
        })
      }



    })
  },
  getpagelist(rest, strwhere) {
    var that = this
    if (rest == 1) {
      that.setData({
        modellist: []
      });
      if (!strwhere) {
        strwhere = {}
      }
    }
    this.setData({ isload: true })
    distr_shareholderbill.sharesoffset(that, rest, strwhere).then(function (result) {
      var updatemdoel = {};
      if ((result["code"] == "over" && result["obj"]) || result["code"] == "loadmore") {
        if (rest == 1) {
          updatemdoel["modellist"] = result["obj"]["modellist"];
        } else {
          if (result["obj"]["modellist"].length > 0) {
            updatemdoel["modellist"] = that.data.modellist.concat(result["obj"]["modellist"]);
          }
        }
      }
      wx.stopPullDownRefresh();
      updatemdoel["isload"] = false

      that.setData(updatemdoel);
    })
    return;
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    this.getpagelist(-1)

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})